package top.wshape1.largefileupload.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.wshape1.largefileupload.domain.R;
import top.wshape1.largefileupload.domain.vo.CheckFileRespVO;
import top.wshape1.largefileupload.domain.vo.CheckFileVO;
import top.wshape1.largefileupload.domain.vo.UploadFileRespVO;
import top.wshape1.largefileupload.domain.vo.UploadFileVO;
import top.wshape1.largefileupload.service.UploadService;

/**
 * @author Wshape1
 * @version 1.0
 * @description
 * @since 2025-01-24
 */

@RestController
@RequestMapping("/upload")
@Slf4j
@RequiredArgsConstructor
public class UploadController {

    private final UploadService uploadService;

    @PostMapping("/checkFile")
    public R<CheckFileRespVO> checkFile(@RequestBody CheckFileVO checkFileVO) {
        log.info("checkFileVO:{}", checkFileVO);
        CheckFileRespVO vo = uploadService.checkFile(checkFileVO);
        return R.ok(vo);
    }

    @PostMapping("/uploadFile")
    public R<UploadFileRespVO> uploadFile(UploadFileVO uploadFileVO) {
        log.info("uploadFileVO:{}", uploadFileVO);
        UploadFileRespVO vo = uploadService.UploadFile(uploadFileVO);
        return R.ok(vo);
    }

}
